package com.push.xu.xpush.base;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;

import com.push.xu.xpush.constant.PushAction;
import com.push.xu.xpush.core.ZPushReceiverInterface;
import com.push.xu.xpush.entity.PushCommand;
import com.push.xu.xpush.entity.PushMsg;
import com.push.xu.xpush.util.TransmitDataManager;

public abstract class BasePushReceiver extends BroadcastReceiver implements ZPushReceiverInterface {

	@Override
	public final void onReceive(Context context, Intent intent) {
		String action = intent.getAction();
		Parcelable parcelable = TransmitDataManager.parsePushData(intent);
		if (PushAction.RECEIVE_COMMAND_RESULT.equals(action)) {
			onCommandResult(context, (PushCommand) parcelable);
		} else if (PushAction.RECEIVE_NOTIFICATION.equals(action)) {
			onReceiveNotification(context, (PushMsg) parcelable);
		} else if (PushAction.RECEIVE_NOTIFICATION_CLICK.equals(action)) {
			onReceiveNotificationClick(context, (PushMsg) parcelable);
		} else if (PushAction.RECEIVE_MESSAGE.equals(action)) {
			onReceiveMessage(context, (PushMsg) parcelable);
		} else {
			onOtherMessage(context);
		}
	}

}
